import axios from 'axios';
import qs from 'qs';
import {Message} from 'element-ui'

//统一的跨域前缀
axios.defaults.baseURL = 'http://localhost:8089/';
axios.defaults.timeout = 5000;

 axios.interceptors.request.use((config) => {
  if(config.method === 'post') {
		//将参数格式利用qs进行序列化转化
    config.data = qs.stringify(config.data,{arrayFormat: 'repeat'});
  }
  return config;
}, (error) => {
		return Message.error({message: '请求超时!'});
});

export default axios; 